package guo.controller;

import com.sun.xml.internal.ws.util.CompletedFuture;
import guo.entity.Student;
import guo.entity.User;
import guo.event.StudentEvent;
import guo.event.UserEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;

/**
 * @author: gsq
 * @description: TODO
 * @date: 2024/6/5 9:25
 * @version: 1.0
 */
@RestController
@RequestMapping("/event")
public class TestEvent {

    @Autowired
    private ApplicationEventPublisher publisher;

    @GetMapping("/publish")
    public String eventPublish(){
        Student student = new Student();
        student.setId(1);
        student.setName("张三");
        student.setLetter("letter");
        student.setPhone("sadad");
        User user = new User();
        user.setId(2);
        user.setName("nihao");
        user.setPhone("sada");
        publisher.publishEvent(new StudentEvent(student));

        System.out.println("ok");
        return "ok";
    }
}
